-
Notifications
You must be signed in to change notification settings - Fork 419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement FastCircle
component
#6290
Conversation
Just reading the title of this makes me want to go "no why is this being proposed even". I'd hope we can not resort to cpp style microoptimisations like this. But maybe it's just me 🤷 I'd be much more okay with this replacing |
My current proposals:
|
highp vec2 pixelPos = v_TexRect.zw * 0.5 - abs(v_TexCoord - v_TexRect.zw * 0.5); | ||
highp float radius = min(v_TexRect.z, v_TexRect.w) * 0.5; | ||
|
||
highp float dst = max(pixelPos.x, pixelPos.y) > radius ? radius - min(pixelPos.x, pixelPos.y) : distance(pixelPos, vec2(radius)); | ||
|
||
highp float alpha = v_BlendRange.x == 0.0 ? float(dst < radius) : (clamp(radius - dst, 0.0, v_BlendRange.x) / v_BlendRange.x); | ||
|
||
o_Colour = getRoundedColor(vec4(vec3(1.0), alpha), vec2(0.0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the use of v_TexRect
here.
- Have you tested textures at all? It looks like you're not actually sampling the texture.
- What about cropped textures? (
Texture.Crop()
) - Does this work for rotated ellipses (textured and non-textured)? I assume so but it should be checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the thing: I'm abusing texture coordinates to pass screenspace size to the shader without uniforms (to compute antialiasing). This new circle isn't a sprite, so textures can't be set. (in my defence current circle isn't a sprite either)
Regarding rotation: I'll add test showing it's working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To clarify: I'm not trying replicate CircularContainer
, I'm simplifying one particular usage of it, which is CircularContainer
with a plane Box
with no texture inside (Circle
class) to avoid masking overhead in cases where multiple circes are being drawn consecutively (GPU side) and reducing total drawable count (CPU side)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the thing: I'm abusing texture coordinates to pass screenspace size to the shader without uniforms (to compute antialiasing).
As a side note I can apply hacks explored in this pr to the Triangles
shader since it's being widely used in the game to eliminate uniform buffer. Will pr after checking whether performance gain is worth doing so.
If this "fast" circle can't be applied universally then I'm not super interested in this imo. |
My current position on this is I'm not sure where it fits in right now but I'm not totally opposed to it. Or at least I'm not totally opposed to the idea of having fast untextured primitives. |
The part that stops me from replacing Slight tidbit: different systems handle draw calls very differently and it's very likely yours handles much better than, say, a mobile GPU. |
a separate shader is going to interrupt batching, so we need to be sure that's what we want (probably not?) |
What you have to understand is that it already interrupts batching as a result of masking. It all depends on whether the gains of SSBO can be realised. |
Which current
There's a way to use the same shader, but I'm not sure if it's too ugly or some better approach can be implemented.
|
This comment was marked as outdated.
This comment was marked as outdated.
Okay, this one is easily fixable. |
This PR's still in my emails fwiw, just very low priority while working on the many other tasks... I do eventually want to come back and re-read through the above comments + the capabilities offered by the existing I may be okay blindly merging this in as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to merge this one as it is for now to see where things go. Thanks!
Hmm, was kinda hoping this would just replace |
My point is I don't know if this is the best that can be done. It still breaks the batch after all, and in a way that is much harder to prevent. 99% of cases would be fine with just using |
Fair enough |
Adresses #6067, ppy/osu#21495
Pros:
Box
drawable (adds up in demanding scenarios)CircularContainer
Cons (which are holding me back from replacing current
Circle
implementation with this one):Circle
is no longer a container (so is theBox
which I think is fine)Box
has the same properties)CircularContainer
insteadPerformance comparison in demanding scenarios: